/**
 * @param {string} digits
 * @return {string[]}
 */

 let path = []
 let result = []
 const map = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"];
 var letterCombinations = function (digits) {
   const k = digits.length
   if (!k) return []
   if (k === 1) return map[digits].split('')
   result = []
   backtracking(digits, k, 0)
   return result
 };
 
 const backtracking = (digits, k, index) => {
   if (path.length === k) {
     result.push(path.join(''))
     return
   }
   for (const v of map[digits[index]]) {
     path.push(v);
     backtracking(digits, k, index + 1);
     path.pop();
   }
 }